package py.org.atom.seam;

import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Startup;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.ScopeType;

import py.org.atom.seam.entity.BaseUser;

@Name("org.jboss.seam.security.identity")  
@Scope(ScopeType.SESSION)  
@Install(precedence = Install.APPLICATION)  
@BypassInterceptors  
@Startup 
public class Identity extends org.jboss.seam.security.Identity {
 
	private static final long serialVersionUID = -3372881000342180705L;

	private BaseUser user;	
	
	public String logOut(){
		super.logout();
		return "/home.xhtml";
	}	
	
	public BaseUser getUser() {
		return user;
	}

	public void setUser(BaseUser user) {
		this.user = user;
	}
	
	@Override
	public String getUsername(){
		if(this.user == null)
			return null;
		
		return this.user.getId().trim();
		
	}
	
}
